package router

import (
	"admin-nexus-backend/internal/handler"
	"admin-nexus-backend/internal/service"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

// SetupDataPermissionRoutes 设置数据权限管理路由
func SetupDataPermissionRoutes(router *gin.RouterGroup, db *gorm.DB) {
	roleService := service.NewRoleService(db)
	dataPermissionHandler := handler.NewDataPermissionHandler(roleService)

	dataPermissions := router.Group("/data-permissions")
	{
		dataPermissions.GET("", dataPermissionHandler.GetDataPermissionList)             // 获取数据权限列表
		dataPermissions.GET("/:roleId", dataPermissionHandler.GetDataPermissionByRoleID) // 获取指定角色的数据权限
		dataPermissions.PUT("/:roleId", dataPermissionHandler.UpdateDataPermission)      // 更新数据权限
		dataPermissions.DELETE("/:roleId", dataPermissionHandler.DeleteDataPermission)   // 删除数据权限
		dataPermissions.PUT("/batch", dataPermissionHandler.BatchUpdateDataPermissions)  // 批量更新
	}
}
